<template>
  <div>
    <el-card style="width: 80%;margin: 10px">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户名">
          <el-input v-model="form.userName" ></el-input>
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="form.email" disabled></el-input>
        </el-form-item>
        <el-form-item label="行号">
          <el-input v-model="form.bankName" ></el-input>
        </el-form-item>

        <el-form-item label="身份" >
          <el-input v-model="options[form.status].label" disabled>
          </el-input>
        </el-form-item>
<!--        <el-form-item label="身份">-->
<!--          <el-input v-model="form.status" ></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="地址">
          <el-input v-model="form.address" ></el-input>
        </el-form-item>
<!--        <el-form-item label="密码">-->
<!--          <el-input v-model="form.password" show-password></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <div style="text-align: center">
        <el-button type="primary" @click="update">保存</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: "Person",
  data(){
    return{
      form:{},
      options:[
        {
          value:0,
          label:'总经理'
        },{
          value: 1,
          label: '销售部门'
        },{
        value: 2,
          label: '采购部门'
        },{
          value:3,
          label: '会计部门'
        },{
        value:4,
          label: "普通用户"
        }
      ]
    }
  },
  created() {
      let str = sessionStorage.getItem("user")||"{}"
      this.form=JSON.parse(str)
  },
  methods:{
    update(){
      request.put("/user",this.form).then(res=>{
        console.log(res)
        if(res.code==='0'){
          this.$message({
            type:"success",
            message:"更新成功"
          })
          sessionStorage.setItem("user",JSON.stringify(this.form))
        }else {
          this.$message({
            type:"error",
            message:res.msg
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
